1 00:00:00,410 --> 00:00:01,100 Hey there. 2 00:00:01,100 --> 00:00:04,640 We're going to start wrapping up our project by bringing everything together. 3 00:00:04,640 --> 00:00:09,980 Specifically here, we need to fill out our SCP 294 handler server script and require the drink class 4 00:00:09,980 --> 00:00:11,210 that exists for the server. 5 00:00:11,210 --> 00:00:14,660 That way we can get everything set up and we can test out our SCP. 6 00:00:14,870 --> 00:00:20,000 So let's go ahead and go into the server script service and open up our SCP 294 handler. 7 00:00:20,000 --> 00:00:22,580 Inside of here we're only going to need two services. 8 00:00:22,580 --> 00:00:24,830 One is going to be replicated storage. 9 00:00:28,510 --> 00:00:31,120 And then the other service we'll need is the collection service. 10 00:00:31,120 --> 00:00:37,300 That way we can collect all of the ships in our game and, you know, find them using that tag we created 11 00:00:37,300 --> 00:00:38,080 for it. 12 00:00:38,080 --> 00:00:43,720 So inside of our variables section I'm going to create a reference to the communications event. 13 00:00:44,600 --> 00:00:46,490 So we can do replicated storage. 14 00:00:46,820 --> 00:00:49,700 SCP 294 assets communication. 15 00:00:51,020 --> 00:00:54,500 And then we're going to require the drink class. 16 00:00:54,770 --> 00:00:59,510 So we'll require inside of replicated storage SCP 294 assets. 17 00:00:59,510 --> 00:01:02,030 And we can get the drink class for the server. 18 00:01:02,030 --> 00:01:07,130 That way we can execute all of the code inside of this module script and get everything set up and ready 19 00:01:07,130 --> 00:01:07,790 to go. 20 00:01:08,150 --> 00:01:10,610 Now, the other thing I want to do is I want to create a table. 21 00:01:10,610 --> 00:01:17,480 I'm going to call it Scp's, and we're going to use the collection service to get all of the ships that 22 00:01:17,480 --> 00:01:23,300 are tagged with the specific tag we created in the beginning of the lecture, which was SCP 294. 23 00:01:23,300 --> 00:01:25,220 So actually we can create a constant. 24 00:01:25,220 --> 00:01:30,950 For simplicity's sake, I'll just call it SCP tag, and we'll set it to a string of SCP 294. 25 00:01:30,950 --> 00:01:34,910 And this was the tag we set for all of the SCP 294 in our game. 26 00:01:34,910 --> 00:01:40,040 So this is going to collect all of the instances in our game that has this tag, specifically our vending 27 00:01:40,040 --> 00:01:40,790 machine. 28 00:01:41,390 --> 00:01:46,370 And then once we get all of those steps, what we could do is we could loop through every single one 29 00:01:46,370 --> 00:01:53,900 of those and set up a function to be attached to our proximity prompt that is inside of our steps. 30 00:01:53,900 --> 00:01:58,190 And then when that proximity prompt gets activated by a player, we can tell them to open up the guy 31 00:01:58,190 --> 00:02:01,670 on their screen so we can create a function. 32 00:02:01,670 --> 00:02:03,890 We'll call it on prompt triggered. 33 00:02:04,130 --> 00:02:06,740 And I don't know how many steps are going to be in the game. 34 00:02:06,740 --> 00:02:12,530 So it's better to have a function that each of the steps can refer to, rather than creating a new lambda 35 00:02:12,530 --> 00:02:14,330 function for every single step. 36 00:02:14,540 --> 00:02:18,440 And this function will just take a player which gets passed by the triggered event. 37 00:02:18,440 --> 00:02:23,030 So we can loop through every single step in the table steps. 38 00:02:23,510 --> 00:02:31,910 And what we could do is we could do SCP and we're going to find First child, which is a proximity prompt. 39 00:02:31,910 --> 00:02:36,440 And then there's a second property we can pass to this function, which is called recursive. 40 00:02:36,440 --> 00:02:38,150 And we're going to pass true. 41 00:02:38,150 --> 00:02:44,810 And what this does is that this function is now going to search through all the descendants of our SCP. 42 00:02:45,110 --> 00:02:50,210 So instead of looking through the direct descendants of our SCP, which would be just this attachment, 43 00:02:50,210 --> 00:02:55,010 the function is now going to look through all of the descendants, so it'll look an attachment, and 44 00:02:55,010 --> 00:02:58,190 then look to see if there's a proximity prompt, an attachment which there is. 45 00:02:58,190 --> 00:03:00,650 So we're going to grab that proximity prompt. 46 00:03:00,890 --> 00:03:07,100 And once we do that we can access our triggered event and connect the on prompt triggered function to 47 00:03:07,100 --> 00:03:07,850 this event. 48 00:03:07,850 --> 00:03:11,540 And again we're referencing the function to this not calling it. 49 00:03:13,590 --> 00:03:15,690 Now what do we want to do when the prompt gets triggered? 50 00:03:15,720 --> 00:03:22,830 Well, we can use the comms event and fire to this particular player and tell them to enable the GUI 51 00:03:22,860 --> 00:03:26,340 like we defined in our SCP 294 GUI handler. 52 00:03:26,340 --> 00:03:31,170 So right here we're listening to the comms event, and whenever we get told to enable the GUI, we're 53 00:03:31,170 --> 00:03:33,330 going to open the GUI on our screen. 54 00:03:33,690 --> 00:03:36,660 And that's all we need to do for our SCP 294 handler. 55 00:03:36,690 --> 00:03:41,850 The main purpose is just to require our drink class, and set up all the SCP so we can go ahead and 56 00:03:41,850 --> 00:03:42,420 use them. 57 00:03:42,420 --> 00:03:48,990 So that now means we should be able to test out our SCP so we can go ahead and do test and play right 58 00:03:48,990 --> 00:03:49,620 here. 59 00:03:50,980 --> 00:03:52,840 And let's see if we can get a cup of air. 60 00:03:52,870 --> 00:03:55,510 So if we go up to our machine and trigger it. 61 00:03:56,240 --> 00:03:58,670 We get called to open guy on our screen. 62 00:03:58,670 --> 00:03:59,480 Very cool. 63 00:03:59,480 --> 00:04:04,460 And we should be able to click these buttons and it'll play the click sound for us and display that 64 00:04:04,460 --> 00:04:05,450 character on the display. 65 00:04:05,450 --> 00:04:09,320 So if I hit a, we get the sound and A is displayed. 66 00:04:09,320 --> 00:04:14,360 We could do I and then R, and then we can hit the enter key to get a cup of air. 67 00:04:14,480 --> 00:04:16,220 As you can see it's now dispensing. 68 00:04:17,300 --> 00:04:18,680 And we get our cup of air. 69 00:04:18,680 --> 00:04:21,500 There's nothing inside of it and we shouldn't be able to drink it either. 70 00:04:21,500 --> 00:04:23,420 So when I click it, there we go. 71 00:04:23,420 --> 00:04:26,150 It gets destroyed and it tells us there is nothing in the cup. 72 00:04:26,150 --> 00:04:27,980 And then this message should fade out. 73 00:04:27,980 --> 00:04:28,940 Perfect. 74 00:04:28,940 --> 00:04:31,370 So our sap is all now good and set up. 75 00:04:31,370 --> 00:04:34,190 That means we can go ahead and create some more drinks. 76 00:04:34,190 --> 00:04:39,920 So for example, let's go ahead and go to our pre-made drinks module script and let's create a new drink. 77 00:04:39,920 --> 00:04:41,810 For example let's create a drink. 78 00:04:41,810 --> 00:04:44,690 We could do something like we'll just call it juice. 79 00:04:44,780 --> 00:04:49,130 And all the strings we can accept for this particular drink can be something like apple juice. 80 00:04:49,370 --> 00:04:51,170 We can just do juice. 81 00:04:51,770 --> 00:04:56,900 We could do maybe grape juice, whatever the case may be for this particular drink. 82 00:04:56,900 --> 00:05:01,190 And then down here we can create a new section for this particular drink. 83 00:05:01,190 --> 00:05:04,280 Remember to have the exact same key of juice. 84 00:05:05,390 --> 00:05:12,380 And then for the consumed message, we could say something like it tastes like a sweet juice. 85 00:05:13,650 --> 00:05:17,220 We'll change the dispense sound to be the regular dispense. 86 00:05:17,220 --> 00:05:17,610 Sound. 87 00:05:17,610 --> 00:05:19,200 So dispense. 88 00:05:19,860 --> 00:05:21,930 And then this cup isn't going to be empty. 89 00:05:21,930 --> 00:05:24,870 So we're just going to set this to false. 90 00:05:25,440 --> 00:05:29,250 And we can give it a name like, uh, juice. 91 00:05:30,050 --> 00:05:33,890 And then we'll set the transparency to something maybe like 0.5. 92 00:05:33,890 --> 00:05:36,140 And then we can select an interesting color. 93 00:05:36,140 --> 00:05:39,350 Actually I'll change this to from RGB. 94 00:05:40,420 --> 00:05:42,700 And we can select a color for our juice. 95 00:05:42,700 --> 00:05:48,880 Maybe give it like a slight kind of yellowish tannish hue, maybe something like that. 96 00:05:49,690 --> 00:05:51,850 And now that we have this new drink in here. 97 00:05:51,850 --> 00:05:53,680 Oh, don't forget to put a comma here. 98 00:05:53,680 --> 00:05:58,630 For every new key value pair you define in our table, that means we should be able to go back and play 99 00:05:58,630 --> 00:06:01,240 our game and dispense this new drink. 100 00:06:01,990 --> 00:06:04,540 All right, so we interact, we open the GUI. 101 00:06:04,540 --> 00:06:07,030 Let's go ahead and get a cup of juice. 102 00:06:11,230 --> 00:06:12,190 Perfect. 103 00:06:12,700 --> 00:06:14,500 Here, we got our cup of juice. 104 00:06:14,530 --> 00:06:16,930 Um, it's not really looking like juice, but it's fine. 105 00:06:16,930 --> 00:06:18,100 We can change that later. 106 00:06:19,090 --> 00:06:19,420 And. 107 00:06:19,420 --> 00:06:19,960 Perfect. 108 00:06:19,960 --> 00:06:21,700 It tastes like a sweet juice. 109 00:06:22,180 --> 00:06:22,630 Alrighty. 110 00:06:22,630 --> 00:06:27,640 So now let's get to the fun part and create some functionality for some specific drinks. 111 00:06:27,640 --> 00:06:32,260 So for example, in the beginning I showed you that we created a cup of pain and got punched in the 112 00:06:32,260 --> 00:06:32,830 face. 113 00:06:32,830 --> 00:06:34,900 So let's go ahead and create that drink. 114 00:06:34,900 --> 00:06:39,340 So inside of pre-made drinks we can define a new drink in here I'll just call it pain. 115 00:06:40,410 --> 00:06:43,230 And someone could input anything like pain. 116 00:06:43,230 --> 00:06:45,030 I don't know, suffering. 117 00:06:45,850 --> 00:06:52,660 Injury, hurt, whatever they could type in whatever they like, and we can give them a cup of pain. 118 00:06:52,660 --> 00:06:55,570 So we'll define another new key value pair here. 119 00:06:56,510 --> 00:06:57,980 So for pain. 120 00:07:00,090 --> 00:07:09,270 We could say something like, you feel like you just got punched by Mike Tyson for the dispense sound. 121 00:07:09,270 --> 00:07:12,120 We can set something interesting like dispense sound. 122 00:07:12,270 --> 00:07:15,510 Angry is empty, will be set to false. 123 00:07:15,510 --> 00:07:17,520 And then we can change the name to pain. 124 00:07:17,610 --> 00:07:22,020 And then we could go ahead and change the color to maybe set it to, like, a deep red. 125 00:07:23,260 --> 00:07:26,680 And we can change the material, maybe to something like neon. 126 00:07:27,530 --> 00:07:31,280 And then we can set the transparency to be completely opaque. 127 00:07:33,310 --> 00:07:37,330 And actually I'll change this red color to be not as intense. 128 00:07:37,540 --> 00:07:38,860 Something like that. 129 00:07:40,180 --> 00:07:44,170 And then we can go to our pre-made drinks function module script. 130 00:07:44,170 --> 00:07:46,960 So inside of replicated storage we'll open that up. 131 00:07:47,780 --> 00:07:53,150 Pre-made drink functions, and we could go ahead and define a function for this particular drink of 132 00:07:53,150 --> 00:07:53,570 pain. 133 00:07:53,570 --> 00:07:57,050 So I'm going to get rid of this and define it for our pain drink. 134 00:07:57,050 --> 00:08:02,090 And I'm going to want to refer to replicated storage inside of this module script. 135 00:08:03,980 --> 00:08:07,580 And that's because I want to be able to access the comms event. 136 00:08:07,580 --> 00:08:11,270 So replicated storage, get our assets communication. 137 00:08:11,270 --> 00:08:16,400 And that way I can tell the server to do some server side effects, which specifically for this drink 138 00:08:16,400 --> 00:08:18,680 we want to remove some health from the player. 139 00:08:18,680 --> 00:08:23,660 And then we could also use the tween service as well to tween some things on the client screen. 140 00:08:23,660 --> 00:08:25,340 So we'll get the tween service. 141 00:08:26,690 --> 00:08:28,610 So when the player drinks the pain drink. 142 00:08:28,610 --> 00:08:29,930 What do I want to happen? 143 00:08:29,960 --> 00:08:34,550 Well, first I want to be able to reference the player's character and you'll see why in a moment. 144 00:08:34,550 --> 00:08:39,530 So I'll just call it current char and it's going to be equal to the drink object dot owner. 145 00:08:39,530 --> 00:08:41,450 And we're going to get their character. 146 00:08:41,660 --> 00:08:47,390 And then I'm going to put an if statement here to make sure that this script is running on the client. 147 00:08:47,390 --> 00:08:49,520 So at the top here what I could do. 148 00:08:50,040 --> 00:08:54,480 Is I'll create a boolean, I'll call it is client equal to. 149 00:08:54,480 --> 00:08:57,180 And that means we're going to have to access the run service. 150 00:08:57,180 --> 00:08:58,710 So run service. 151 00:08:59,780 --> 00:09:02,360 And then we can use the function is client. 152 00:09:02,360 --> 00:09:07,850 That way we can differentiate whether or not this function is being called on the server or on the client. 153 00:09:07,850 --> 00:09:13,940 So if is client then we'll execute client functionality in here. 154 00:09:13,940 --> 00:09:16,100 And at the end just return true. 155 00:09:16,100 --> 00:09:21,740 Otherwise any other functionality that isn't for the client will be executed down here, which will 156 00:09:21,740 --> 00:09:22,580 be the server. 157 00:09:22,580 --> 00:09:24,410 And we can just do return true as well. 158 00:09:24,410 --> 00:09:25,400 It doesn't really matter. 159 00:09:25,400 --> 00:09:30,530 So on the client, um, what I want to do is I want to create two new instances. 160 00:09:30,530 --> 00:09:33,950 One is going to be something called a color correction effect. 161 00:09:33,950 --> 00:09:36,320 So color correction effect. 162 00:09:36,320 --> 00:09:38,720 And let me actually show you this as an example. 163 00:09:38,720 --> 00:09:44,180 So if I were to put a color correction effect in my camera I can tweak some of these things and tint 164 00:09:44,180 --> 00:09:46,280 the screen color to be something different. 165 00:09:46,280 --> 00:09:50,090 So as you can see I can tint the color of the screen to be whatever. 166 00:09:50,090 --> 00:09:51,890 I can change the brightness. 167 00:09:52,710 --> 00:09:55,500 Uh, that's a little bright, but as you can see, I can tweak the brightness. 168 00:09:55,500 --> 00:09:58,260 I can tweak the contrast so I can make it. 169 00:09:58,560 --> 00:09:59,310 Oops. 170 00:09:59,460 --> 00:10:03,900 Do something like that, change the contrast or make it higher. 171 00:10:03,900 --> 00:10:09,360 And of course, I can also change the saturation to make the colors more saturated or more washed out. 172 00:10:10,220 --> 00:10:11,060 Pretty neat. 173 00:10:11,060 --> 00:10:14,990 So we're going to use this color correction effect to make it look like we got punched. 174 00:10:16,640 --> 00:10:19,280 So we'll get a new color correction effect. 175 00:10:19,280 --> 00:10:22,340 And then I'm also going to get a blur as well. 176 00:10:22,340 --> 00:10:25,580 So a new blur effect. 177 00:10:25,580 --> 00:10:29,060 And again this instance just blurs the screen. 178 00:10:29,060 --> 00:10:30,800 So that's a pretty simple one. 179 00:10:31,770 --> 00:10:37,680 And then what I could do with these is I could tween them or fade them to appear on the screen. 180 00:10:37,680 --> 00:10:43,650 So for our color, what I could do is I'll create a tween, I'll call it tween color and use the tween 181 00:10:43,650 --> 00:10:47,460 service to create a new tween on our new color instance. 182 00:10:49,280 --> 00:10:50,780 And we'll make it last. 183 00:10:50,780 --> 00:10:53,120 Something like maybe 0.3 seconds. 184 00:10:55,240 --> 00:10:56,680 And what do I want to tween? 185 00:10:56,680 --> 00:11:01,090 Well, I want to tween the tint color to be equal to a new color. 186 00:11:01,090 --> 00:11:04,150 So color three from RGB. 187 00:11:04,660 --> 00:11:11,140 And I want to tween the screen to be completely black like like kind of like we lost consciousness. 188 00:11:11,140 --> 00:11:15,160 So actually if I put this color correction effect back in here, and if I tween it to be all the way 189 00:11:15,160 --> 00:11:19,270 completely black, as you see our screen turns completely dark. 190 00:11:19,270 --> 00:11:22,870 So I want to apply that effect to make it look like we got punched and knocked out. 191 00:11:22,870 --> 00:11:25,360 And then we will wake back up from our knockout. 192 00:11:25,360 --> 00:11:27,940 So we'll tween it to be completely black. 193 00:11:27,940 --> 00:11:31,690 And then for the blur I'm going to bore the screen as well. 194 00:11:31,690 --> 00:11:36,010 So I'll call this Tween Blur equal to the tween service we'll create on our. 195 00:11:36,130 --> 00:11:39,970 For instance this one can be a little bit longer. 196 00:11:39,970 --> 00:11:42,430 Maybe we'll tween it to be 0.6 seconds long. 197 00:11:42,730 --> 00:11:46,330 And the blur instance has a property called size. 198 00:11:47,000 --> 00:11:49,670 And we'll set it equal to something like 12. 199 00:11:49,670 --> 00:11:51,830 So it'll be a little bit bored on our screen. 200 00:11:51,830 --> 00:11:55,700 And of course you can define this as a string or you can literally just type it out as well. 201 00:11:55,700 --> 00:11:57,020 It doesn't really matter. 202 00:11:57,050 --> 00:12:02,990 Now using the current character that we just stored inside of this variable, I want to listen for when 203 00:12:02,990 --> 00:12:03,950 the player dies. 204 00:12:03,950 --> 00:12:08,330 So we get their humanoid and listen to the died event, and we're going to connect a Lambda function 205 00:12:08,330 --> 00:12:08,900 to it. 206 00:12:08,900 --> 00:12:14,300 And that's because when the player dies, I want to remove these instances from their camera, because 207 00:12:14,300 --> 00:12:19,820 what we're going to do is we're going to set the parent of these onto the player's current camera. 208 00:12:19,820 --> 00:12:26,420 So what we could do is if the player dies, we want to check if we still have the color and blur. 209 00:12:26,420 --> 00:12:31,910 So if we have not destroyed them yet by the end of the script, then we want to make sure to destroy 210 00:12:31,910 --> 00:12:33,530 them when the player dies. 211 00:12:34,290 --> 00:12:37,410 And then we want to make sure to set them to nil as well. 212 00:12:40,280 --> 00:12:45,350 So this function is going to be extremely important for removing effects off of our screen when the 213 00:12:45,350 --> 00:12:46,280 player dies. 214 00:12:46,280 --> 00:12:53,270 Otherwise, once we do that, um, by default when we create a new board instance, it's going to have, 215 00:12:53,270 --> 00:12:55,250 I believe, a default of 24. 216 00:12:55,250 --> 00:12:59,180 So we want to make sure to set the blur dot size equal to zero. 217 00:12:59,800 --> 00:13:06,190 And then we can set the color dot parent equal to the workspace and get the current camera of the player, 218 00:13:06,340 --> 00:13:08,560 and then do the same thing for the blur. 219 00:13:09,430 --> 00:13:14,680 And then I also want to reference actually the sound service game. 220 00:13:15,830 --> 00:13:20,570 The sound service, because in there there is an audio file we can use for being punched in the face. 221 00:13:20,570 --> 00:13:25,100 So if we go to the sound service I have a punched audio file here. 222 00:13:25,100 --> 00:13:28,580 So we'll play that when they consume the drink so we can do sound service. 223 00:13:29,870 --> 00:13:34,640 Get the SCP 294 sounds folder, access our punch sound and play that. 224 00:13:34,640 --> 00:13:41,240 And once we play that sound, we can tween the blur onto our screen. 225 00:13:42,270 --> 00:13:43,860 As well as the color. 226 00:13:45,200 --> 00:13:46,790 And let me play this again. 227 00:13:47,060 --> 00:13:54,020 There is a slight delay for when this sound plays the punch noise, so we can actually maybe yield for 228 00:13:54,020 --> 00:13:58,790 like 0.1 seconds before we actually fade the screen to be black. 229 00:13:59,090 --> 00:14:04,940 And I'm going to wait for our tween color. 230 00:14:05,590 --> 00:14:08,530 To finish, so we're going to wait for that to finish. 231 00:14:09,760 --> 00:14:13,450 And once we wait, we'll need to create a new tween for the color on our screen. 232 00:14:13,450 --> 00:14:20,980 So we'll override tween color to a new tween so we can use the tween service to create a new tween on 233 00:14:20,980 --> 00:14:22,510 our color instance. 234 00:14:23,910 --> 00:14:27,240 And this tween will last something like 0.1 seconds. 235 00:14:29,010 --> 00:14:35,730 And we want to tween the tint color to be a slightly red. 236 00:14:35,730 --> 00:14:40,050 So from RGB we can set it to be of a slightly red color. 237 00:14:40,050 --> 00:14:43,800 So if we go on here, we can make the color. 238 00:14:44,190 --> 00:14:47,430 Maybe something around there that would be good. 239 00:14:47,430 --> 00:14:51,990 So our screen is slightly red and then we can play this tween again. 240 00:14:53,380 --> 00:15:00,100 And then once we play this tween, um, we can tell the server to remove health off of us so we can 241 00:15:00,100 --> 00:15:06,340 use the comms event, and we can fire to the server to execute some functionality for this particular 242 00:15:06,340 --> 00:15:06,640 drink. 243 00:15:06,640 --> 00:15:12,970 So if you remember in our drink class for the server in our comms event, we can have an action of drink 244 00:15:12,970 --> 00:15:13,450 effects. 245 00:15:13,450 --> 00:15:16,210 And we pass the ID of this drink object. 246 00:15:16,210 --> 00:15:22,180 And if the player owns that drink object and the effects debounce hasn't been set to true yet, then 247 00:15:22,180 --> 00:15:28,840 it's going to execute all the functionality for the server so we can fire the server to execute some 248 00:15:28,840 --> 00:15:33,160 particular drink effects, and we can pass the drink object.id. 249 00:15:34,300 --> 00:15:39,160 And actually, one more thing I'll do is I'll override our blur tween as well. 250 00:15:39,520 --> 00:15:41,500 So we'll set it to a new tween. 251 00:15:43,740 --> 00:15:49,320 And I'll make this tween actually last something like perhaps 10s long. 252 00:15:52,110 --> 00:15:54,210 So we'll set the size equal to zero. 253 00:15:54,210 --> 00:15:57,480 So our blur will fade out of our screen over time. 254 00:15:57,900 --> 00:16:00,210 And we can play this tween as well. 255 00:16:01,930 --> 00:16:05,320 And then we're going to wait for our tween blur to finish. 256 00:16:05,320 --> 00:16:07,870 So tween Blur dot completed. 257 00:16:07,870 --> 00:16:11,020 We're going to wait for that, which will be about 10s. 258 00:16:11,560 --> 00:16:16,810 And then once those 10s are up, we're going to ensure that we still have this color and blur on our 259 00:16:16,810 --> 00:16:22,570 screen, because in those 10s we've waited, the player could have reset and the color correction effect 260 00:16:22,570 --> 00:16:24,640 and the blur effect could have already been destroyed. 261 00:16:24,640 --> 00:16:28,810 So we need to make sure that color and blur are not nil. 262 00:16:28,810 --> 00:16:30,340 So if color and blur. 263 00:16:30,340 --> 00:16:33,940 So if they still exist, then we need to destroy them. 264 00:16:35,030 --> 00:16:35,510 We can do. 265 00:16:35,510 --> 00:16:35,990 Borer. 266 00:16:35,990 --> 00:16:37,040 Destroy. 267 00:16:38,100 --> 00:16:40,050 And then set bore equal to nil. 268 00:16:40,050 --> 00:16:44,190 That way it won't be able to destroy it here when our player dies. 269 00:16:44,520 --> 00:16:49,980 And then we should also fade the color back out from our color correction effect. 270 00:16:50,520 --> 00:16:58,470 So actually, one last time, what we could do is we could override the tween color again to a new tween. 271 00:16:58,470 --> 00:17:01,170 So we get the tween service created on our color. 272 00:17:01,970 --> 00:17:04,160 And we can make this last. 273 00:17:04,250 --> 00:17:07,310 I don't know maybe about 10s as well. 274 00:17:08,300 --> 00:17:10,910 And we'll set the tent color. 275 00:17:12,840 --> 00:17:14,310 Just to be equal to white. 276 00:17:14,310 --> 00:17:19,080 So color three dot new or dot from RGB. 277 00:17:19,770 --> 00:17:23,010 We'll just set it to be completely white because that's the default color. 278 00:17:23,460 --> 00:17:25,800 And we can play that again as well. 279 00:17:29,270 --> 00:17:34,400 And then once those are finally up, then we'll just destroy the blur, set it to nil, and we could 280 00:17:34,400 --> 00:17:37,850 do the same thing for the color, so color will destroy it. 281 00:17:39,150 --> 00:17:41,790 And we'll make sure to set it to nil as well. 282 00:17:43,760 --> 00:17:49,280 Now, of course, you could also store the connection for our humanoid in a variable. 283 00:17:49,280 --> 00:17:50,900 You can just call it connection. 284 00:17:51,170 --> 00:17:56,270 And instead of needing to set border and color to nil, you could also just destroy the connection as 285 00:17:56,270 --> 00:17:56,690 well. 286 00:17:56,690 --> 00:17:59,150 So we'll actually do both here just in case. 287 00:17:59,150 --> 00:18:03,050 So we'll get this connection and we'll disconnect it. 288 00:18:03,530 --> 00:18:07,940 So now what I need to do is I need to fill out the server functionality for this particular drink. 289 00:18:07,940 --> 00:18:13,160 Because when we tell the server to execute the effects for this drink, um, what do I want to do? 290 00:18:13,160 --> 00:18:19,520 Well, I just want to remove some health from this particular player so we could get their current character 291 00:18:19,520 --> 00:18:26,600 that we stored originally here in this variable, and we can set their humanoid's health to be less, 292 00:18:26,600 --> 00:18:30,920 or we can use a function on our humanoid called take damage. 293 00:18:30,920 --> 00:18:36,290 And what we could do is maybe we could just reduce their health by half so we can access their humanoid, 294 00:18:36,290 --> 00:18:38,690 get their health, and divide it by two. 295 00:18:38,720 --> 00:18:40,880 That way they lose half of their health. 296 00:18:40,880 --> 00:18:43,280 So that's all the server is going to do here. 297 00:18:43,280 --> 00:18:45,860 So this is our server functionality. 298 00:18:48,110 --> 00:18:50,780 And this is the client functionality. 299 00:18:52,830 --> 00:18:57,540 So now that we have this applied, let me go ahead and delete these other effects that I've already 300 00:18:57,540 --> 00:18:58,440 put on our camera. 301 00:18:58,440 --> 00:19:00,570 And we can go ahead and play test the game. 302 00:19:01,790 --> 00:19:03,860 And let's go ahead and get a cup of pain. 303 00:19:03,860 --> 00:19:05,960 So let's get a cup of pain. 304 00:19:08,570 --> 00:19:11,990 We get the, uh, very angry dispense sound. 305 00:19:13,570 --> 00:19:17,860 And when we drink our cup, we should have our screen fade to black. 306 00:19:17,860 --> 00:19:21,580 Our screen should be blurry, slightly red, and we should lose half of our health. 307 00:19:25,940 --> 00:19:26,840 So there we go. 308 00:19:26,840 --> 00:19:29,000 We've imitated a punch on our screen. 309 00:19:29,000 --> 00:19:33,980 Our screen went black and we lost half of our health thanks to the replication done by the server. 310 00:19:34,430 --> 00:19:37,280 So let's go ahead and actually demonstrate that again. 311 00:19:46,880 --> 00:19:47,960 So we get our cup of Penn. 312 00:19:47,960 --> 00:19:48,740 We drink it. 313 00:19:49,490 --> 00:19:54,620 Screen fades to black, our screens all blurry, and then it slowly fades out. 314 00:19:55,310 --> 00:20:00,380 Now, I did make a little error in my logic here because our screen didn't turn red. 315 00:20:00,930 --> 00:20:06,240 And that's because I play the tween, and because this play function doesn't yield, it immediately 316 00:20:06,240 --> 00:20:07,800 set the color to white. 317 00:20:07,800 --> 00:20:12,120 So what I do is for our tween color. 318 00:20:14,030 --> 00:20:17,240 Um, well, wait for this event to finish. 319 00:20:17,240 --> 00:20:20,060 So twin color dot completed. 320 00:20:20,060 --> 00:20:21,020 Wait. 321 00:20:21,790 --> 00:20:27,580 So that way our screen is red for a little bit, and then we can fade it out towards white. 322 00:20:27,580 --> 00:20:30,130 So we can actually make this effect last longer as well. 323 00:20:30,130 --> 00:20:33,220 So instead of 10s we can make it last maybe 20s. 324 00:20:34,460 --> 00:20:38,930 That way we could see if our screen stays red for a little bit longer. 325 00:20:39,620 --> 00:20:41,270 So we go and drink. 326 00:20:52,230 --> 00:20:53,310 So we get our cup of pain. 327 00:20:53,310 --> 00:20:53,970 We drink it. 328 00:20:54,690 --> 00:20:55,170 There we go. 329 00:20:55,170 --> 00:20:59,610 Now our screen is red and it stays red for quite a while. 330 00:20:59,640 --> 00:21:03,720 Our screen's kind of blurry because we're recovering after we drank a cup of pain. 331 00:21:04,760 --> 00:21:06,920 As you can see, we can't drink our cup anymore. 332 00:21:06,920 --> 00:21:08,900 But once our effects end. 333 00:21:09,690 --> 00:21:11,310 Our cup should get deleted. 334 00:21:11,310 --> 00:21:15,000 So any second now, our cup, there we go. 335 00:21:15,000 --> 00:21:20,580 So our cup gets deleted because when we execute our drink functionality here, the threat of execution 336 00:21:20,580 --> 00:21:24,510 is jumping into our handler function and executing all the client stuff. 337 00:21:24,510 --> 00:21:29,970 And then once that's finally all over, then it'll go and destroy the drink and tell the server to destroy 338 00:21:29,970 --> 00:21:31,380 the drink as well. 339 00:21:31,740 --> 00:21:36,660 Alrighty, so we're almost finished with our SCP project, and the next lecture, we're going to be 340 00:21:36,660 --> 00:21:40,680 wrapping everything up and fixing a few things, so I'll go ahead and see you there.